using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using kxcxw.Data.Entities;

namespace kxcxw.Data.Mapping
{
	public class SysItemDetialMap : EntityTypeConfiguration<SysItemDetial>
	{
		public SysItemDetialMap()
		{
			// Primary Key
			this.HasKey(t => t.ItemDeitalID);

			// Properties
			this.Property(t => t.ItemDeitalID)
				.IsRequired()
				.HasMaxLength(36);
				
			this.Property(t => t.ItemID)
				.HasMaxLength(36);
				
			this.Property(t => t.ItemDeitalPID)
				.HasMaxLength(36);
				
			this.Property(t => t.itemDetialName)
				.HasMaxLength(100);

            this.Property(t => t.OrderID).IsRequired();
				
			// Table & Column Mappings
			this.ToTable("SysItemDetial");
			this.Property(t => t.ItemDeitalID).HasColumnName("ItemDeitalID");
			this.Property(t => t.ItemID).HasColumnName("ItemID");
			this.Property(t => t.ItemDeitalPID).HasColumnName("ItemDeitalPID");
			this.Property(t => t.itemDetialName).HasColumnName("itemDetialName");
			this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.OrderID).HasColumnName("OrderID");
            Property(t => t.ImgInfo).HasColumnName("ImgInfo");

			// Relationships
			this.HasOptional(t => t.SysItemDetial2)
				.WithMany(t => t.SysItemDetial1)
				.HasForeignKey(d => d.ItemDeitalPID);
				
			this.HasOptional(t => t.SysItemInfo)
				.WithMany(t => t.SysItemDetials)
				.HasForeignKey(d => d.ItemID);
				
		}
	}
}

